Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

emerika's avatar

Error compiling template if there are <script></script> tags

In the Chrome inspector -- I see Error compiling template -- followed by a ton of errors if there are any script tags in my blade file.

For instance a file like below has no errors.

@extends('spark::layouts.app')

@section('content') @endsection

However, one like this: @extends('spark::layouts.app')

@section('content') @endsection

I see this error a lot:

  • Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as , as they will not be parsed.

How can I include scripts in a page without creating these issues?

Thanks a lot.

0 likes
3 replies
jlrdw's avatar

Does it happen if your script tags are placed at bottom of view only, not a section.

emerika's avatar

That seems to be the answer. Thanks a ton!

Cronix's avatar

It's because Spark is using Vue. You'd have to edit the vue component, or make a new one and pass that to the main component. Or, put the additional scripts in the footer or something like suggested where the script tags are not a part of the vue component.

Please or to participate in this conversation.