Support » Plugin: LiteSpeed Cache » Invalid minification of js files containing template string

  • Resolved rafaucau

    (@rafaucau)


    I noticed that my code stopped working after being deployed to the production site.

    const galleries = document.querySelectorAll(".gallery");
    galleries.forEach((gallery) => {
        Glightbox({
            selector:  `#${gallery.id} a`,
            ...options,
        });
    });
    

    It turned out that Litespeed removes the space from the template string on minification.
    So

    `#${gallery.id} a`

    becomes

    `#${gallery.id}a`

    The solution is to write the code like this: "#" + gallery.id + " a".
    However, it would be nice if the template strings worked as they should.

    • This topic was modified 10 months, 2 weeks ago by rafaucau.
    • This topic was modified 10 months, 2 weeks ago by rafaucau.
    • This topic was modified 10 months, 2 weeks ago by rafaucau.
    • This topic was modified 10 months, 2 weeks ago by rafaucau.
    • This topic was modified 10 months, 2 weeks ago by tobifjellner (Tor-Bjorn Fjellner).
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Invalid minification of js files containing template string’ is closed to new replies.