pandell / Spagety

Other
0 stars 0 forks source link

Inlining Build Tool #15

Open cjasinsk opened 10 years ago

cjasinsk commented 10 years ago

Look into creating a build tool that could be run within node.

A user could specify branches / paths that they would like to inline, to reduce the number of requests needed.

This tool would traverse the graph loading all resources, then write a new html file that inlined all the html components together. It could also combine all css files together into 1 file as well. Lastly, perhaps looking at merging multiple viewModels together into a single file, mimmicking the hierarchy of the pages.

So if a user wanted #!/a/b/f/k it would first load all the resources independantly, then write a new inline file, that no longer requires external loads for each html, since they are inserted directly into their parent nodes. Likewise, if b and k have their own css files, then these 2 files after they are scoped, could be merged together into a single file.

This tool would be helpful with reducing the amount of requests needed within a production environment. The common paths could all be inlined, while the uncommon paths could be left to be lazily-loaded.

Another interesting feature would be to be able to create profiles. Different optimizations for different types of users. For example, an admin user could have all the admin tasks inlined, where as a regular user would not have the admin tasks inlined, but instead a different portion of the website. This could allow for different optimizations for different user types. The rootViewModel or the session could store the user type and add this to the requests it sends to the server to get the appropriate optimized resources.

Ex: admin may have #!/a/c/i/m inlined, where as a regular user may have #!/a/b/f/k optimized.

As an admin when the first page is loaded, it already has c/i/m already there, but if they wanted to go to #!/a/b then they would lazily-load the b as needed.

Likewise the user would have #!/a/b/f/k inlined. If they wanted to go to c then they would request just the c file.

So on the server, it would store each independent module, as well as optimized versions for different user types. This could be a useful tool to look into.