T
TypeScript is a transpier, a superstructure over JavaScript, its purpose is to write a more beautiful code if it's very rude. Unfortunately, it's not much he can do for you.What you're talking about is collecting files, minimizing them is called a collector. There's a famous javascript in the world. http://gulpjs.com/ they, to the extent I know, use most js programmers. I can't consult him because I'm working in another field, but I can guarantee that he can handle these tasks, as far as I know, TypeScript is calmly compiling in js, you just need to put a flame.AboutUltimately, the big file that's received needs to be used not entirely at all, but on a certain page, only some part of it. For example, for the product ' s page to create a product class and skirt only its and cat events, it defines, but on the page, everything in the product should not be summoned and should not be bindered, so that it has its class.There are two decisions here. First - js-way is AMD, Asynchronous Module Definition in Link http://requirejs.org/docs/whyamd.html ♪ You're just saying in the violin that he needs, and he pulls the necessary files himself. So you can only be loaded by requiring.js and a file with your own bindes, and there's a chain of custody through the bind violin. This creates a cloud of requests, but it's a real js-approach that ensures uniformity.The second solution is a collection on the server's side that requires certain things from the server (e.g., https://github.com/kriswallsmith/assetic ) The page simply indicates which files should be collected and handed over, for example, Symfony can do this:{% javascripts filter="coffee" filter="uglifyjs2"
"/app/legacy.js"
"/app/modern.coffee"
output="/app/combined.js"
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
It's very cool and uncool at the same time. From the pros:Absolute flexibility in modulesOne request from frontline to serverFrom minus:Beckend is starting to run the front.Front Frontedou has to think about how to turn around if the file doesn't prove necessary.I would therefore recommend a first approach.And finally the third. Since it's refacturing, why don't we go any further and use a real frimetre (e.g.) http://emberjs.com/ ? He himself will monitor and respond to the necessary elements on the page, destroying the 90 per cent Band problem.