This file contains 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
const svgElem = document.createElementNS("http://www.w3.org/2000/svg", "svg"); | |
const useElem = document.createElementNS("http://www.w3.org/2000/svg", "use"); | |
useElem.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#down-arrow"); | |
svgElem.appendChild(useElem); |
This file contains 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
function getKeyByValue(object, value) { | |
return Object.keys(object).find(key => object[key] === value) | |
} | |
const map = {"first": "1", "second": "2"} | |
getKeyByValue(map, "2") // second |
This file contains 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
var str = "I like turtles. Do you? Awesome! hahaha. lol!!! What's going on????"; | |
var result = str.match( /[^\.!\?]+[\.!\?]+/g ); | |
console.log(result[0]) | |
console.log(result.join(" ")) |
This file contains 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
export function camelize(str: string) { | |
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()) | |
} |
This file contains 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
<picture> | |
<source srcset="images/desktop.svg" media="(min-width: 1000px)"/> | |
<source srcset="images/mobile.svg"/> | |
<img class="" width="" height="" src="images/desktop.svg" alt=""/> | |
</picture> |
This file contains 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
(() => { | |
"use strict"; | |
function handleNavbarSticking() { | |
const topHeader = document.querySelector(".js-top-header"); | |
const navbar = document.querySelector(".js-sticky-navbar"); | |
const height = navbar.offsetHeight; | |
if ( isOutOfViewport( topHeader ) ) { |
This file contains 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
<!-- More info here: https://dev.to/aryaziai/improving-speed-with-lazy-loaded-youtube-videos-autoplay-3f1l --> | |
<iframe | |
class="video" | |
width="560" | |
height="315" | |
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" | |
allowfullscreen="allowfullscreen" | |
loading="lazy" | |
srcdoc=" |
This file contains 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
<select name="country"> | |
<option value="AF">Afghanistan 🇦🇫</option> | |
<option value="AO">Angola 🇦🇴</option> | |
<option value="AL">Albania 🇦🇱</option> | |
<option value="AD">Andorra 🇦🇩</option> | |
<option value="AE">United Arab Emirates 🇦🇪</option> | |
<option value="AR">Argentina 🇦🇷</option> | |
<option value="AM">Armenia 🇦🇲</option> | |
<option value="AG">Antigua and Barbuda 🇦🇬</option> | |
<option value="AU">Australia 🇦🇺</option> |
This file contains 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
import loadPlugins from "gulp-load-plugins"; | |
const plugins = loadPlugins(); | |
const { src, dest } = require("gulp"); | |
const BUILD_ASSETS = "assets/"; | |
function buildHtml() { | |
return src("path-to-folder/*.html") | |
.pipe(useref({ noAssets: true })) | |
.pipe( | |
plugins.inject( |