You may not need a JavaScript framework (iii) __java

Source: Internet
Author: User
HTTP/2

The HTTP protocol has been overridden. This is not the text of the agreement, but binary. Binary protocols are more efficient and error-prone. HTTP/2 connections are multiplexing, simply-allowing you to transmit multiple responses simultaneously in a single connection.

The Http-protocol has been completely rewritten. The protocol is no longer textual, but binary. Binary protocols are much more efficient and less error-prone. HTTP/2 connections are also multiplexed put it which-to your to simply-allows transfer multiple Y within a single connection.

In addition, the HTTP2 implements the service-side push. Before I talk about the polyfill of the functions encountered.

Additionally, HTTP/2 implements Server-push. And this is the feature I am getting at earlier I am talking about polyfilling.

Service-side push allows the server to send data to the client without requiring a client request. For example, the client requests index.html follow the server response index.html Ah, styles.css Ah, script.js ah, etc., will be packaged together for you to send over.

Server-push allows your server to send additional data this client may not have requested. For instance, a client requests index.html Andyour server responds with index.html, Style.css, Script.js, polyfill-1.js D polyfill-2.js.

While this does not help to reduce the volume, the key is that there is no need for a lot of communication between the server and the client back and forth. Furthermore, you can reduce the size by adding a server-side configuration to match the browser version of the request and dynamically decide which polyfills to push on each client.

This doesn ' t solve the application size problem and but it reduces the number of round-trips to the server. However, you can reduce the size by adding server-side configuration to match the requesting browser version and Dynamically decide which polyfills to push on a per-client basis.

This is where Webpack and other module loaders/bundles lag behind, because bundling is a bad practice for HTTP/2. The only reason the bundle is used now is to reduce the number of requests to the server, but since HTTP/2 itself is multiplexing, server push is implemented, and each resource can be cached independently, this is no longer the case. If you are bundling and using HTTP/2 at the same time, you will not apply to all caching features provided by HTTP/2. Imagine that if you update only one line in a JS file, the user will have to download the entire package again (even if there is no updated code) and cache it. If there is no bundle, only the files that have been changed need to be downloaded again, which can save a lot of traffic bandwidth. This also makes your site more suitable for mobile users, because bandwidth and parsing operations are very much considered for mobile devices.

This is where Webpack and other module loaders/bundlers are falling behind, because bundling are bad practice with HTTP/2. The only reason bundling is being used are to reduce the amount of requests made to the server, but since-HTTP/2-is MULTIPL Exed, implements Server-push and can independently cache each asset the "is no" longer the case. If you are would bundle and still use HTTP/2, you wouldn ' t get all caching capabilities. Because imagine if you are update a single in a js-file, the user would have to download the entire bundle (EV En the code that hasn ' t been updated) and cache it. Without bundling, only the changed file would have to is re-downloaded-thus reducing the bandwidth for drastically With large amounts of traffic. It also makes your site much more mobile-friendly as bandwidth and parsing are a huge on mobile.

In addition, you can implement bundled strategies for http/1.x visitors and SPDY live HTTP/2 visitors are not bundled.

Additionally, you could serve a bundled application for http/1.x visitors and a non-bundled application for SPDY & HTT P/2 visitors.

HTTP/2 has been widely supported by browsers. At the time of writing, 70.15% of visitors have been supported by the new agreement. The key problem is that the host provider, the webmaster, did not configure the Web server properly.

HTTP/2 is widely supported by Web browsers already. At the time of writing, 70.15% of visitors has support for the updated protocol. The problem is this hosting providers and website Owners haven ' t enabled it in their Web server configurations. Program Structure Application structure

When you start a project, it is essential that you plan ahead and assess your needs. If this is a real single page site, you certainly don't need a framework. A index.html, style or dotted script is enough. For example, if you want to use Stylus and ES2015, you can use NPM init, install Babel and Stylus, and use their command-line versions in NPM run scripts. You can also add monitoring for a faster development environment.

When you start a project, it's always a good idea to plan ahead and estimate roughly what your need. If it ' s a truly single page site (1 page), definitely don t need a framework. A single index.html, styling and optional the script is enough. If you are want to use Stylus and ES2015 for example, can NPM init, install Babel and Stylus and use their command-line ve Rsions in a npm run script. You are could also add watch for a more snappier development environment.

Package.json:

{
  ...
  " Scripts ": {
    " Build ":" Babel src-d Dist & Stylus Src/styles-o dist/styles & CP src/index.html dist/index.html ",
    Dev": "Watch ' npm run build './src"
  }
The NPM run build runs and you have a production-ready build.

There's a small, but nice Gist, you can look at more clips.

NPM run build and your have a production-ready build.

There ' s a small, but great Gist that you can look in for more snippets. Package Manager and Module Loader Package Manager & Module Loader

The package Manager may be used when your application becomes larger. I recommend JSPM because it is based on SYSTEMJS, and Systemjs is based on the standard ES6 Module loader specification.

You know, however, that this encounters the same problem as the webpack that HTTP/2 supports, so you might want to use NPM and build a simple script that replicates the relationships you rely on during the build.

When your application grows large, it could is option to use a package manager. I recommend JSPM as it is based on SYSTEMJS which in turn are based on the standard ES6 module loader spec.

Know though that this introduces the same problem as Webpack with HTTP/2 support, so you might as a. D Build a simple script this copies your dependencies during build.

It is not a good way to use copy and paste from a library to handle dependencies. This is the problem with the browser's package manager, where the current Package Manager implementation (except Bower) injects some kind of script into the production version because of support for module loading. Due to the cheer of different module formats, the module loading introduces many problems, and can not run well at present in HTTP/2. Before this problem is resolved, you can stay in NPM, as I mentioned earlier, or copy and paste what you need. This is, of course, a problem with application size and dependencies.

Using copy-paste of ' libraries ' is ' not ' bad way of handling your dependencies. That ' s the way it is before package managers for the browser existed and the current Package manager Implementations-ex Cept for Bower-inject Some kind of the script into your the build production to have due for module support. Module loading introduces many problems due to the cheer amount of different module formats and does not currently play VE Ry with HTTP/2. Until That's fixed, you may as very just stay with NPM as I mentioned earlier or copy-paste what. This is the course also a question of application size and the amount to dependencies you. Summary Conclusion

I really hope that you can try at least one more native web development, I've said so much. If you're not used to native Web APIs or DOM APIs for some reason, and want to stick to your framework, I don't blame you. Do what you feel comfortable with and try to do your best. Finally, I would like to apologize, this must be a very serious post. Cheers, Tom.

I really hope that I ' ve inspired the to try out native web development at least one more time. If You are some reason don ' t feel comfortable with the native Web APIs or DOM APIs and want to stick framework, I Don ' t blame you. Do what your feel comfortable with and try to make the the situation! Lastly, I want to apologize the this had to be a slack post. Cheers, Tom. Updating update:

I read some comments and feedback about react. I'm sorry, I didn't know it, but now try as much as I can. However, please note that my original text is not to say that your frame is not good, but to ask yourself if you really need it. Think about it, open your heart, try to write JavaScript yourself, and rebuild the old project with the native WEB API and DOM API. How much time do you think it will take? How much bandwidth you will save. Will it be more complicated? I understand that react is just a view layer, but in fact many of you are using things like redux-and other plug-ins. The result is a fairly heavy application.

react is not concerned with performance, it is concerned about handling UI state, this is a difficult problem.

I ' ve read some comments and feedback about mentioning react. I apologize that I didn ' t go more in-depth into it, but I ' ll try to cover as much as possible now. Note though, which I message for you are not this your framework is bad-it. D it. Play a bit with the thought, open your mind and try to picture yourself re-building your previous project using Vanilla Ja Vascript, native Web API and DOM API. How much more does you would take it? How much bandwidth would you save and would it is much more complicated? I understand that react are only the view-layer, but in reality many of your are using things like redux with It-along wit H Other plugins. The result of this is a pretty heavy application. react is not about performance, it's about handling UI state, and which is hard.

Yes, but that's not what I meant. UI state is not difficult for the size of your application. An ordinary JavaScript object has the highest level of state, and using Object.observe (or Proxy, Object.observe probably obsolete) is enough to enable you to implement automatic UI state synchronization between components. It's not necessarily more complicated than that. I can totally understand why big companies like Facebook and YouTube need this kind of functionality, but it doesn't make sense for your blog editors or 7-class online stores.

building your own implementation will make it difficult for the next person to come in and maintain your work.

Yes, but that's not the I message for you. UI state isn ' t hard for the size your applications are. A Plain JavaScript Object holding the top-level state, and using Object.observe (or Proxy since Object.observe has been MA De obsolete) should be more than enough for your to implement automatic UI State synchronization functionality, across comp Onents. It doesn ' t have to be more complex than that. I can definitely understand why large companies like Facebook and YouTube need such-functionality, but it doesn ' t make Sen Se for your blog editor or e-store with 7 categories. building your own implementations makes it hard for the "next person" this comes in to do maintenance of your >

This is indeed a problem, but through proper commentary and documentation, it should not be. It's not like you're writing a new framework-you're writing a wrapper for a feature that you often reuse. Finally, it is an ordinary JavaScript and Web API. Just because you no longer use the frame doesn't mean you have to build something too complex. If you are a member of the Fortune 500 company and want to do a project, you may write your own framework, because the Facebook solution may not solve your problem.
When images > 500KB, JavaScript size doesn't matter.

This is indeed a problem, but with proper commenting and documentation it shouldn ' t to be. It ' s not as you ' re writing a new framework-you ' re writing wrappers for functionality to often you. In the "end it" s plain JavaScript and Web APIs. Just because you don ' t use a framework anymore doesn ' t mean, have to build something overly. The case of your web app becoming part a fortune company, you ' d probably write your own framework either As Facebooks solutions would probably not solve your. JavaScript size doesn ' t matter so much when there are images > 500KB.

Unfortunately, the JavaScript engine must parse, interpret, and execute the code. Most frameworks perform heavy tasks during the startup phase of DOM document, adding more time to the first rendering. Even if they have good connections, this is very bad for mobile devices.

it can become bad, spaghetti code-it's impossible to continue to maintain development.

Unfortunately it does. The JavaScript engine has to parse, interpret and execute the code. Most frameworks runs heavy tasks in the startup-phase of the document, adding even more time to a. This is really bad on mobile, even if they have a good connection. It'll turn out the bad, spaghetti code-impossible to continue development of.

For beginners, you must learn how to write clean, reusable code. As mentioned earlier, write more documents.

you haven't built any complex applications yet.

For starters, "VE got to learn" to write clean, reusable code. As mentioned earlier, document your code! You are haven ' t built any complex applications.

I have built some real-time synchronization of offline support, notifications and data for complex applications. Really don't know how to answer, it feels like a completely unrelated question. I've written about Angular,react,aurelia,angular 2.0,jquery and polymer, and it's not easy to find, Aurelia is probably the most inconspicuous thing I like about it.

I ' ve built a few complex applications with Offline-support, notifications and data this is synchronized in real-time. Don ' t really know what to answer, feels like a completely irrelevant. I ' ve worked with angular, react, Aurelia, angular 2.0, jQuery and polymer. None of them are very pleasing to work with, Aurelia is probably I favorite for it unobtrusiveness. What I want to say is ... My message for you

What I'm trying to say is not that your frame is too bad, I want to inspire you to try the native Dom and Web API again. There are a lot of new features and things that you may not have seen yet.

My point is not this your framework sucks or anything like so, I wanted to inspire your to try out the native DOM and We b API again. There ' s a lot of new features and stuff that you probably haven ' t seen yet.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.