Inline JS breaks

#1
Hi,

I am pasting here my post from StackOverflow to see if there is anything related or known in Litespeed space.

Original post: https://stackoverflow.com/questions...nexpected-token-on-inline-js-js-script-breaks

Pasted:
I am facing an issue that has baffled and actually exhausted me for hours.
I have tried so many different things, have done and still doing various debugging techniques but I am very tired and would seek for some help of any kind.

I will post the very basics for start, in case someone has any helpful idea/suggestion to unstack me, and I might be adding further information or more code as we go if needed.

I am working on a Joomla site and on a custom component view I place an inline jQuery script at some point of my html output.

The problem is that while everything works well on my localhost, when I upload it online the javascript breaks in whatever point I try to create variables that contain html. Then the browser will auto-close the script tag with `</script>` and the rest of the js code will be output as html.

So for example, the following script:

<script>
(function($)
{
$(document).ready(function()
{

var loader = '<div id="loader"><div>';

});
})(jQuery);
</script>

will end up to something like below:

<script>
(function($)
{
$(document).ready(function()
{

var loader = '<div id="loader">';
</div></script>

});
})(jQuery);
</script>

*Another clue that I just got is that the issue seems to be when I upload this on Litespeed server.
I tested this on 2 different servers with Litespeed and then on 1 Apache.
The one on the Apache server works fine (like on my localhost).

This is my complete inline script, just in case anyone is in place to catch anything that I am missing.
###
The complete inline script has been removed, due to characters limit. Refer to the original post in SO.

### Updates on this post:
It seems that the issue appears on Litespeed environment. I tried to switch-off Litespeed and enable Apache for testing purposes on one of those 2 litespeed servers, but for some unknown reason, Apache failed to start, so I have opened a ticket with that hosting provider to check that issue also.
I will post back here once the Apache issue is resolved and I have managed to make the test on the same exact machine with Apache running.
 
Last edited:

serpent_driver

Well-Known Member
#2
I never heard about browser will auto-close html tags. You better should verify if Joomla has an internal function doing that, if you insert HTML code via Joomla editor.

This is not a LSWS issue.
 
Top