Single javascript file vs MVC [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Im just getting into app development and it seems that the style is to use an MVC style of coding where you have an app.js, controller.js, and service.js and etc. All codepens I see are always a single HTML file plus a single js file. What is the difference between these two styles? It seems like building putting them all in a single js file would be more convenient but why would someone go through the trouble of splitting up the code?

The short answer: Codepen is a sandbox for testing, not app development. Putting all your code in a single file may be convenient for a simple example, but once you have to scroll through thousands of lines of spaghetti code, you'll soon change your mind. Putting your code into separate files, or modules, is worth the trouble; you can always minify before moving to a production environment.

Related

Does React run in the browser? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Once i created a build from my project i decided to take a look at the JS file produced in the build process and i found uglified code that i couldn't understand but at the first glimpse it seems that there is much code added by React that will work in the browser!
Now i am confused about what is the part of React that works in the browser, is the whole library added to the build file or certain functions from React + my code??
I understand that JSX part need to be compiled to work in the browser but what about other react functions, how they looks like after build?? how are they used by the browser??

How to make my website load faster built with laravel vue js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
so I just got hired , and I was giving the task of optimizing a new site they want to launch soon , https://bizguruh.com , so far I have tried everything I can,reduced image size, but it doesn't seem to be helping , any ideas from anyone would be greatly appreciated please
Well I just visit your side, You can do one thing in that. I have noticed there are many CSS and JS files used in your site. But many of them in their actual version.
You can minify all CSS and JS file's code with Laravel's Mix Feature
This will convert the whole code in single line so It won't take much load
not all your js and css are minified, for example app.js is really huge, minify it may help a lot.

How to structure the JS? Put the code in a unique file or require the necessary JS code in the file where its used? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Do you know if is better to have a unique file with all JS or is better in each file require the specific JS that is necessary for that specific page?
The project sould stay better structured requiring the JS specific for each file.
But in terms of performance do you know if is basically the same or not?
For a small JS snippets is always better to implement it only on pages you need.
But, for big classes, framework or huge functions is better use single file with an CDN. That way is better performance and finaly better to maitenance and for developing is better to stay organized.
As second, in single file you can easily do minified version fully automated.
I prefer creating a unique JavaScript file and then linking it to the html file. It is the most efficient and organized way of structuring your code. But if the amount of code is very small and only required for that single page, inline JavaScript is preferred.
Performance: External JavaScript is always faster because the browser can cache an external file but Inline JavaScript will always be loaded afresh and hence is slower.

The better way to maintain css, js, font-cion, image's versions? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have few css files for a site and some css properties are shared through all of them. Plus there are also few js files. font icons file and images that I constantly updating. Whenever I tried to push to main repository, i had to make sure each file version are bumped using "?=number". I am seriously tired of doing this.
Is there a better way to do URL version bumps all together? Any help would be appreciated.
Additional info: I am using IIS7/8 and developing in windows system by using HG Mercurial. Back end uses asp.net visual basic, mysql.
Since you're using ASP.NET, your .NET devs can set a variable that holds a common increment number that you can use as the number in the ?v=number part. So, you just change all of your CSS/JS files to consume the variable one time only. For example:
string version = ConfigurationManager.AppSettings["VersionNumber"];
If you're using bundling, there is a better answer here:
How to make bundles unminify and list individual files when using a cookieless static content server?

Deploying my site, lots of small script files. Long loading time [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I've built a web application.
In my application I have many javascript and css files .
They are separated based on my application's logic.
I am talking about close to 20 of these files (each file is 2 kb +-).
They seem to take quite a while to download (6 - 10 seconds altogether).
What would you do to cut down the download time? Are there any best practices in this field?
Thank you
Join all JavaScript and all CSS files into one big JS and one big CSS file, and minify them.
You can compress your file by removing spaces, use short variable names, etc. Try looking for tools that are around for that purpose. Also, you can add all scripting to one file so that only one files needs to be downloaded and you can introduce some caching mechanism to prevent downloading the script over and over again.
http://rakaz.nl/2006/12/make-your-pages-load-faster-by-combining-and-compressing-javascript-and-css-files.html
[http://driven-monkey.com/?p=97]
check these out

Categories

Resources