This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm config ls -l --registry => to see the registry. | |
| npm config set registry https://registry.npmjs.org => to set the desired registry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .npmignore | |
| Blacklisting files with npmignore | |
| The .npmignore file works the same way as a .gitignore file. | |
| If a file is listed in the .npmignore file, the file will be excluded from the package. | |
| Important note: If you have a .npmignore file, npm will use the .npmignore file. npm will ignore the .gitignore file altogether. | |
| (Many developers mistakenly believe npm will use both .npmignore and .gitignore files. Don’t make the same mistake!). | |
| .npmrc | |
| This file is a configuration file for NPM, it defines the settings on how NPM should behave when running commands. | |
| There are several ways to configure NPM. You can do it via: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //jsconfig ==> to make editor recognize absolute path. | |
| { | |
| "compilerOptions": { | |
| "baseUrl": ".", | |
| "paths": { | |
| "~/*": ["/*"], | |
| "@src/*": ["src/*"], | |
| "@any-other-folder/*": ["src/client/../any-other-folder/*"] ==> absolute path to any other folder | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How to check if a Browser Tab is active or not? 🔥 | |
| 0. Stop video if the user changes the browser tab | |
| 1. Reduce Polling Rate of Data from API | |
| 2. Stop music if the user moves out | |
| document.visibilityState | |
| // 'visible' | |
| document.addEventListener("visibilitychange", function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The crossorigin attribute, valid on the <audio>, <img>, <link>, <script>, and <video> elements, provides support for CORS, defining how the element handles crossorigin requests, | |
| anonymous CORS requests for this element will have the credentials flag set to 'same-origin'. | |
| By default (that is, when the attribute is not specified), CORS is not used at all. The "anonymous" keyword means that there will be no exchange of user credentials via cookies, client-side SSL certificates or HTTP authentication. | |
| Example: crossorigin with the script element | |
| You can use the following <script> element to tell a browser to execute the https://example.com/example-framework.js script without sending user-credentials. | |
| <script src="https://example.com/example-framework.js" crossorigin="anonymous"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| go to chrome://flags/ | |
| Allow invalid certificates for resources loaded from localhost. Choose enabled. Chrome will relaunch without certificate | |
| verification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Before installing nvm, run this in terminal: touch ~/.bash_profile | |
| After, run this in terminal: | |
| curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | |
| Important... - DO NOT forget to Restart your terminal OR use command source ~/.nvm/nvm.sh (this will refresh the available commands in your system path). | |
| In the terminal, use command nvm --version and you should see the version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| permutations | |
| const possiblePermutations = (str) => { | |
| const result = []; | |
| let dupStr = ''; | |
| let tempStr = str; | |
| result.push(str); | |
| for(let i = 0; i < str.length; i++) { | |
| // if(i === 0) { | |
| // result.push(str); | |
| // continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DOMContentLoaded – the browser fully loaded HTML, and the DOM tree is built, but external resources like pictures <img> and stylesheets may not yet have loaded. | |
| load – not only HTML is loaded, but also all the external resources: images, styles etc. | |
| beforeunload/unload – the user is leaving the page. | |
| When the browser processes an HTML-document and comes across a <script> tag, it needs to execute before continuing building the DOM. | |
| That’s a precaution, as scripts may want to modify DOM, and even document.write into it, so DOMContentLoaded has to wait. | |
| So DOMContentLoaded definitely happens after such scripts. | |
| There are two exceptions from this rule: | |
| Scripts with the async attribute, that we’ll cover a bit later, don’t block DOMContentLoaded. | |
| Scripts that are generated dynamically with document.createElement('script') and then added to the webpage also don’t block this event. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Preload | |
| Generally it is best to preload your most important resources such as images, CSS, JavaScript, and font files. | |
| preload is different from prefetch in that it focuses on fetching a resource for the current navigation. | |
| prefetch focuses on fetching a resource for the next navigation. It is also important to note that preload does not block the window's onload event. | |
| Allows the browser to set resource priority therefore allowing web developers to optimize the delivery of certain resources. | |
| The browser can determine if the request is compliant with the content security policy by referencing what is defined in the as attribute. | |
| An example of preloading fonts. If you are preloading links with CORS enabled resources you must also include the crossorigin attribute. | |
| <link rel="preload" href="https://example.com/fonts/font.woff" as="font" crossorigin>. | |
NewerOlder