The first line is a line of Javascript code.
The second line is a line of HTML.
They cant exist in the same context back to back like that.
Either you’re in an HTML context, and there should be a </script> tag after line 1 (and a <script> tag somewhere above it),
or you’re in a Javascript context, and the HTML doesnt belong there,
or you’re in some other scripting context that requires explanation.
Ok.
Can you provide two lines that we test to solve tow lines JavaScript content inside JS file or PHP code to echo inside hooks all the time all JavaScript content or a javascript line?
Is there a demo for hooks using JavaScript content?
@m_hutley is right you’re trying to insert HTML in the middle of a JavaScript file, which is causing the syntax error. In JavaScript files, you can’t just stick HTML in the middle of it; it’s not an HTML file.
var script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=XXX&language=XX®ion=XX';
document.head.appendChild(script);
Just replace 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=XXX&language=XX®ion=XX' with your actual script URL. This should load your external script without causing any syntax errors.
As for the window.Parsley.setLocale ('fr'); line, you can keep it as is in your JavaScript file.
I have tested JavaScript is without an error but it will cause an issue inside Google Console as Google API is not detected when using your code and API Key.
You missed how to add also elements to the script: async defer.
Maybe it can be added to the above great script.
Currently, it works in Mozilla but Google Chrome is not working. I have to wait due to Cache. Currently it is jQuery is not compatible with Quirks Mode. Maybe Chrome reacts differently as Mozilla.