-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
The project "Javascript-concatenating-strict-files-" explains the difficulty in strict mode when concatenating two js files. Based on that knowledge wrapping the body of more than one js file is an option to overcome the difficulty.
For the sake of completeness there will be aspects which can also be found in "Javascript-concatenating-strict-files- wiki".
Wrapping is a synonym for engulfing something. In this project the code of every file is engulfed in a function as follows:
//Wrapping the function into a function
(function()
{
function a_function_name()
{
//body
}
//function call by name
a_function_name();
})();
The first function is calling automatically itself by the last parenthesis.
The content of two files were merged into one file with the help of gulp. These files are "no strict.js" and "strict.js".
Gulp is a toolkit for automating time consuming processes in developement. There are very well made tutorials based on grunt and gulp. Here are some recommendable on youtube by Tech CBT:
In the file "README_TO_GULP.txt" is a quick explanation how to install and use gulp for this project.
To concatenate the two files "no strict.js" and "strict.js", a file "gulpfile.js" is needed which can be downloaded from the code section of this github project. If not interested, there is no need to make all the work, because "example1" and "example2" contain already the results.
This contains the concatenated js code in the following sequence.
- first - "no strict.js"
- second - "strict.js"
This contains the concatenated js code in the following sequence.
- first - "strict.js"
- second - "no strict.js"
"example1" and "example2" show no concatenated trouble with the strict mode. They work both as they should!
This knowledge was gained:
-
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman
-
What is the purpose of wrapping whole Javascript files in anonymous functions like “(function(){ … })()”? asked by Andrew Kou and answered by Vivin Paliath
-
Difference between function with a name and function without name in Javascript asked by Shwet and answered by Jordan
-
Grunt JS: Quick Introduction by Tech CBT
-
Gulp JS: Quick Introduction (in 30 min) by Tech CBT
-
How to Install Gulp.js on Windows by Ollie Mc Farlane
-
gulp-concat by Eric Schoffstall