Skip to content

Instantly share code, notes, and snippets.

@sorcamarian
sorcamarian / vanilla-DOM-Javascript-add-remove-class-value-IE-a.js
Last active September 13, 2018 15:54
Vanilla DOM Javascript - remove and add class - IE, old browsers
// Add class
DOMElement.className += " one";
// Example:
// var el = document.body;
// el.className += " two"
// Remove class
function removeDOMClass(element, className) {
var oldClasses = element.className,
@sorcamarian
sorcamarian / Node.js File Looper
Created March 26, 2019 13:24 — forked from adamwdraper/Node.js File Looper
Loop through all files in a given directory with node.js
var fs = require('fs');
var walkPath = './';
var walk = function (dir, done) {
fs.readdir(dir, function (error, list) {
if (error) {
return done(error);
}
YUI().use('node', 'anim', function (Y) {
Y.on('domready', function () {
(function () {
Y.one('body').delegate('click', function (e) {
e.preventDefault();
var anchor = e.currentTarget.getAttribute('href');
var scrollAnim = new Y.Anim({
node: Y.one(Y.UA.gecko || Y.UA.ie || !!navigator.userAgent.match(/Trident.*rv.11\./) ? 'html' : 'body'),
to: {
scrollTop : Y.one(anchor).getY()
@sorcamarian
sorcamarian / ImageLoader-examples.js
Created August 3, 2022 14:37 — forked from foleyatwork/ImageLoader-examples.js
How to run Squarespace's ImageLoader manually.
// For all images.
var allImages = document.querySelectorAll('img[data-src]');
for (var i = 0; i < allImages.length; i++) {
ImageLoader.load(allImages[i]);
}
// For a single image.