Skip to content

Instantly share code, notes, and snippets.

View xavianaxw's full-sized avatar
🥰

Xavian Ang xavianaxw

🥰
View GitHub Profile
@xavianaxw
xavianaxw / defer-css.js
Created May 2, 2019 05:59
Script to defer CSS if non-critical to improve PageSpeed
// List of css file(s) to be deferred
var deferred_css = [
"example-1.css",
"example-2.css",
];
function insertCss(value, index) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = value;
@xavianaxw
xavianaxw / get-query-param.html
Last active November 12, 2019 23:16
Hubspot | getQueryParam() | Passing classes to menu item from Dashboard
{# Helpers: getQueryParam #}
{# Returns the query value by handle #}
{# Parameters #}
{# url | URL | Required #}
{# parameter | Parameter name | Required #}
{# How to import this macro to my module #}
{# {% from 'NOW_002_Website/helpers/get-query-param.html' import getQueryParam %} #}
@xavianaxw
xavianaxw / lazyload-with-observer.js
Created March 2, 2020 22:18
Snippet to add lazyload + Intersection Observer to a site
/**
* Minified by jsDelivr using Terser v3.14.1.
* Original file: /npm/intersection-observer@0.7.0/intersection-observer.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(){"use strict";if("object"==typeof window)if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)"isIntersecting"in window.IntersectionObserverEntry.prototype||Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}});else{var t=window.document,e=[];o.prototype.THROTTLE_TIMEOUT=100,o.prototype.POLL_INTERVAL=null,o.prototype.USE_MUTATION_OBSERVER=!0,o.prototype.observe=function(t){if(!this._observationTargets.some(function(e){return e.element==t})){if(!t||1!=t.nodeType)throw new Error("target must be an Element");this._registerInstance(),this._observationTargets.push({element:t,entry:null}),
@xavianaxw
xavianaxw / related-blog-posts-callback.html
Created February 25, 2022 01:13
Hubspot | {% related_blog_posts %} callback and resize_image_url() in JS
@xavianaxw
xavianaxw / pre-commit
Last active August 9, 2022 23:57
Git hook to compile blendid assets on file change only
#!/bin/bash
# flag to see if compiling is required
should_precompile=0
wp_directory="wp-content/themes/securepay"
# check if there are changes
# wp-content/themes/securepay/css/*
if git diff-index --name-only HEAD | egrep "$wp_directory/css" >/dev/null ; then
should_precompile=1
@xavianaxw
xavianaxw / .hyper.js
Last active January 28, 2023 18:48
Setup for new machine | Hyper Teminal + zsh (with autosuggestions) + spaceship prompt
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: "stable",
@xavianaxw
xavianaxw / slugify.html
Last active July 29, 2023 18:50
Hubspot | slugify() | Converting text into slug for Hubspot
{# Helpers: slugify #}
{# Returns the slug version of a string #}
{# Parameters #}
{# string | String to convert into a slug | Required #}
{# How to import this macro to my module #}
{# {% from '[folder]/slugify.html' import slugify %} #}
{# How to use this macro #}