Currently there are 'known' performance losses from having CSS generated at runtime in the browser. There are other packages that offer built-time CSS generation, e.g. Linaria and Compiled. Will styled-components follow in their footsteps and give us the perfect solution?
Related
I'm learning web-technologies and programming languages. Start learning about frameworks and other stuff. Looking at Bootstrap Front-End Framework. Some details I don't got about this thing.
On official web page it says you can download compiled and sources of Bootstrap. I don't get it, how can Front-End development be "source" and "compiled", ain't they just scripts that browser interprets?
Bootstrap uses LESS files to generate CSS files. The pre-compiled version contains the output from LESS. If you want to modify Bootstrap you'll need the source and then compile the LESS files into CSS.
The term compile is the word LESS uses on their website.
http://lesscss.org/
Doesn't it all compile in the browser upon page load? I'm guessing this means that it was compiled and tested before shipping, but I don't understand why this would need to be advertised.
No, Bootstrap can not run in the browser without the CSS being compiled using LESS.
From Extending Bootstrap:
Bootstrap is made with LESS at its core, a dynamic stylesheet language
created by our good friend, Alexis Sellier. It makes developing
systems-based CSS faster, easier, and more fun.
Since our CSS is written with Less and utilizes variables and mixins,
it needs to be compiled for final production implementation. Here's
how.
Bootstrap is written in LESS, a language that gets "processed" into CSS. It is common to use the word "compilation" to refer to this processing, as compilation is generally speaking the act of translating a language to another one.
AMD modules like requirejs can help save a network round trip if there arises a case when loading a module is never required. But would it offer any gains at all when loading a module is inevitable, for example loading common libraries like jQuery and bootstrap javascript files.
When loading a module is inevitable, requirejs provides no gains at all. On the contrary it hurts your performance. That is because loading a resource by script is always slower that loading it through the html parser. So in general scripts loaded through <script> tag will be faster than loading it via ajax and then evaling it. Same goes with the <img> tags, and for that matter any static resource.
AMD offers benefits only when your scripts are too large and you want to load your modules step by step rather than all at once. If there arises a case when a module might not be needed at all, that is win in terms of network roundtrip and bandwidth, in those cases it should certainly be used.
Libraries like jQuery and bootstrap are required usually upfront, there is no point delegating them to AMD.
I would appreciate any reasonable explanation of the use of BundleConfig and Require.js together in a SPA. How do you choose which scripts should be loaded by BundleConfig when starting the app? Which scripts should NOT be called in BundleConfig and selectively loaded via AMD? Once loaded by BundleConfig, do they have to be called again in require.js' DEFINE statement?
Search as I might, I simply can't find a simple explanation for all this.
Thanks!
BundleConfig will help you get all the script sin the bundle to the client together, in 1 trip. This takes the burden or job off of require.js for that. I often do this for 3rd party scripts, since it is highly likely i need them all client side right away anyway.
Then I can choose to either use require.js to load my scripts as needed (thus AMD) or bundle them too, up front.
Require does not just load things asyncly, though. It also handles the dependency resolution. To me, this is the more important part. It makes sure before I use module A that if it depends on B, which depends on C, which depends on D is resolved first. So they get loaded and run in the proper order.
So whether you use bundling or not, the require.js dependency aspects as super valuable.
As part of a major refactoring of my Node.js app (going DDD), I'm looking for a library that through inspecting code is able to visualize module dependencies (by means of 'requiring' them) between different node-modules.
Visualizing in Table-format is fine, I don't need fancy graphs.
Any Node libraries out there?
If you may accept also some fancy graphs: http://hughsk.github.com/colony/
I do not know if this exists, but I found the following by quick search:
http://toolbox.no.de/packages/subdeps
http://toolbox.no.de/packages/fast-detective
Maybe subdeps is not exactly what you want right now, but I think you could use these projects to make that project yourself?
See also https://github.com/pahen/madge
Create graphs from your CommonJS, AMD or ES6 module dependencies. Could also be useful for finding circular dependencies in your code. Tested on Node.js and RequireJS projects. Dependencies are calculated using static code analysis.
I just published my node-dependency-visualizer, which is a small module, that creates a digraph from your node dependencies. Paired with graphviz/dot you can create a dependency graph as svg (or other image format) which you can include with your documentation, embed in your Readme.md, ...
However, it does not check, whether the dependencies are actually needed in code - not sure, whether the OP meant that with "requiring". Of course this question is old, but this tool might be helpful for others, too.
Sample image (Angluar cli):
I read many times that YUI will load modules dynamically based on need. or based on parent module. Like here it is written
The overlay module will pull in the widget, widget-stack,
widget-position, widget-position-align, widget-position-constrain and
widget-stdmod extensions it uses.
So, how can I determine the final size of data getting downloaded for a web page due to YUI usage.
Actually I was thinking how one can compare the datasize of YUI with that of another library (JQuery).
If you want file size vs functionality comparison, a close approximation based on features would be the simpleyui.js package (though the feature compilation is not 1:1), and be sure to look at gzip size as Tivac said.
Also keep in mind that JS lib file size comparison used as a reason to choose one over another is often a red herring. Your site likely includes a number of images, many of which will easy be larger than the lib and several additional modules. More relevant comparisons would be how the library is structured, what its relative strengths are, what's included out of the box (officially supported features vs 3rd party plugins), its community and documentation, etc. Pretty much any lib will serve your basic DHTML needs, and neither you or your users will notice the difference. Choose what works for you, and helps you build clean, maintainable code that you or your successor won't hate in a few months.
The Configurator will give you a file-size breakdown & automatically selects the needed modules.