Skip to content

Including the code twice #110

Description

@AngelGris

The transformer works great, but I noticed it puts the JS code twice in the inclusion view. This doesn't prevent the transformer from working, but generates extra unnecessary code in the final HTML.
For instance, I created this in a Laravel Controller:

Javascript::put([
  'application' => [
      'name' => config('app.name', 'Laravel'),
  ],
  'user' => [
      'name' => $user->name,
  ]
]);

And this is what I get in the HTML:

<script>
    window.reactBinding = window.reactBinding || {};
    reactBinding.application = {"name":"AppName"};
    reactBinding.user = {"name":"Kemmer-Legros"};
</script>
<script>
    window.reactBinding = window.reactBinding || {};
    reactBinding.application = {"name":"AppName"};
    reactBinding.user = {"name":"Kemmer-Legros"};
</script>

Not big thing in my case, but if you are trying to send a big amount of information from Laravel to JS it could become an issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions