WeCodePixels / theia-sticky-sidebar

Glues your website's sidebars, making them permanently visible while scrolling.
MIT License
569 stars 209 forks source link

Remove executable scripts only. #26

Closed wvega closed 8 years ago

wvega commented 8 years ago

Sometimes script tags can be used to store templates instead of executable code (See KnockoutJS template binding for an example). Removing those scripts can cause other features to break.

This PR modifies the plugin to only remove script tags with an empty type or one that matches a JavaScript MIME type.

liviucmg commented 8 years ago

Just to be sure: This still removes plain <script> tags without a type attribute, right?

wvega commented 8 years ago

Yes, every script where the type attribute is not present, has an empty value, or defined with one of text/javascript, text/ecmascript, application/javascript, application/ecmascript, text/x-javascript or text/x-ecmascript as value, will be removed.

liviucmg commented 8 years ago

Sounds great, thank you! :beers:

wvega commented 8 years ago

Thank you for your quick response and merging this so fast!

rilwis commented 6 years ago

Hello,

We've just discovered a problem with one of our WordPress themes that uses theia library: our users use the custom HTML widget to insert MailChimp popup script (provided by MailChimp), and the popup doesn't show.

Just a question: why do you remove inline script like this? Scripts are still helpful in many situations like above.

liviucmg commented 6 years ago

Hi, because in most cases you don't have a <div class="theiaStickySidebar"> container, so a new one is created and the HTML is moved around, causing the inline script tags to fire twice unless we remove them.

rilwis commented 6 years ago

If the class exists, does the library remove the scripts?

We need to keep the scripts in the sidebar. The problem with current version is if the script is an external script (with src attribute), then there might be a situation that the script has not loaded yet before Theia removes it, making it doesn't execute at all.