I'm a huge nerd 🤓 of vanilla javascript (JS). I've built a few websites on it, as well as a few libraries and still has a long way to go to. This repository serves as a library of commonly used boilerplate code for all things vanilla javascript.
Read this article to learn more about this repository works.
On this repo
$qsa.js
is to alias thedocument.querySelectorAll
to traverse thru DOM elements$.js
is a micro-library for manipulating DOM as angular's$q
format-string.js
is to replace strings as C#String.Format()
snake-case.js
is to style strings to 'snake_case' as Lodash_.snakeCase()
mixin.js
is to allowprototype
option for helper functions as Lodash_.mixin()
script-data-src.js
is magic code to replace<script>
tags with attributedata-src
with newHTMLScripElement
- How to document javascript with JSDoc is a simple article that has the obvious examples
- Air bnb style guide for javascript (es5) is deprecated for vanilla JS but still a good source of information
- Naming functions and the differences is a good explanation.
.apply()
requires input args as a single array- Managing
arguments
in JavScript to learn about leaky arguments arguments
is not purelyArray
type is described on MDN spacification
- Code snippet that allows both
prototype
andfunction
options from thestring.format
example - episode 22 and episode 23 on prototypes is a good start.
- Use of C# like
String.Format
in vanilla JS for various ways to write a helper function
- Serving vanilla JS libraries as modules (.mjs) on the web for full comparison of classic vs. modules
- Creating and using namespace pattern and IIFE explains how to properly expose the library to
global
namespace - Namespace fundamentals when writing vanilla JS libraries by O’Railly library
- Learning JavaScript - namespaces and scoping
- Create your own utility libraries like Lodash and Underscore.js for a walkthru with examples
- Create your own DOM manipulation library like jQuery for replacing jQuery
- Performance testing using
console.time()
andconsole.endTime()
for helper functions
If you were wondering, I'd be happy to have more code snippets here. Have a suggestion or a bug fix? Just open a pull request or an issue. Include the code snippet with a clear file name and the simplest HTML possible.
Licensed under MIT