0

I'm writing a web application where, to avoid a big JS file to load full of code that is rarely used, I decided to modularize and load the modules once they are needed.

The loading works fine: Each piece of JS code is correctly loaded and executed; I used the jQuery method "append" to append a <script> at the end of the <head>.

You can see the result on the picture below.

All pieces of JS code correctly loaded into the browser!

But now the question came when I'd like to remove the code that I no longer need.

I know Facebook has already met the issue due to their big JS size, but on the speech (https://jmperezperez.com/facebook-frontend-javascript/) it seems that they acted as "optimization" of the JS code moving things from the client to the server.

Any idea or clue is strongly welcome.

Thank you very much for your answers.

6
  • What exactly are you trying to remove from where, and why? Remove from the loaded page: you cannot. Remove from the cache: let it expire by setting appropriate caching headers. Remove from your application: just remove the code that loads it. Commented Oct 10, 2018 at 18:57
  • Remove from the loaded page, and from the cache. Commented Oct 10, 2018 at 19:28
  • As I said, the former cannot be done. As for the latter: just let them age out. Commented Oct 10, 2018 at 20:38
  • Why do you even think this is necessary? Do you have any actual issues? Commented Oct 10, 2018 at 20:39
  • @Bergi to prevent issues. There are html properties to set to age out scripts or what else? Commented Oct 11, 2018 at 7:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.