Skip to content

Instantly share code, notes, and snippets.

View Coru89's full-sized avatar

Corey Keller Coru89

  • Freelance
View GitHub Profile
@akojif
akojif / optimize-ga.js
Last active September 2, 2024 09:22
Optimize Core Web Vitals: Fix Render-Blocking JavaScript with Google Analytics
function loadGoogleAnalytics() {
return new Promise((resolve, reject) => {
// Create the script element for Google Analytics
const script = document.createElement("script"); // change the variable to 'var' if Elementor
script.async = true;
script.src =
"https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID_HERE";
//script.onload = resolve;
script.onload = () => {
// Remove this function after testing and un-comment the line above this
@IliasDeros
IliasDeros / shopify_pagination.liquid
Last active November 2, 2023 11:07
Shopify: Show all numbers in pagination, retaining query parameters. Inspired by: https://gist.github.com/kyleaparker/7588995
{% for part in (1..paginate.pages) %}
{% if forloop.index == 1 %}
{% if paginate.next.is_link %}
{%- assign next_page = current_page | plus: 1 -%}
{%- assign page_query_param_old = 'page=' | append: next_page -%}
{%- assign page_url_template = paginate.next.url -%}
{% elsif paginate.previous.is_link %}
{%- assign previous_page = current_page | minus: 1 -%}
{%- assign page_query_param_old = 'page=' | append: previous_page -%}
{%- assign page_url_template = paginate.previous.url -%}