Skip to content

Instantly share code, notes, and snippets.

@CGeohagan
CGeohagan / google_analytics.js
Created October 11, 2023 16:18
GA4 Implementation
import VideoEvents from '@src/metrics/video_events';
import logger from '@src/shared/logger';
/**
* Custom Dimensions Map that is required for UA events with gtag
* This mapping is not required for GA4
*/
const concertCustomDimensionMap = {
'dimension1': 'video_id',
'dimension2': 'video_length',
@Saoming
Saoming / wp-example-optimizations.php
Created August 3, 2023 16:29
(WP) WordPress Optimizations Script
<?php
/**
*
* Scripts and actions to optimize WordPress
*
*/
// Remove block editor
add_filter( 'use_block_editor_for_post', '__return_false' );
@eliofery
eliofery / analytics.html
Last active January 3, 2024 20:29
HTML
<!-- Google Analytics -->
<script async>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');
<!--<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>-->
<!-- Yandex Metrica -->
<script async>(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(XXXXXX, "init", {});
<!--<noscript><img src="https://mc.yandex.ru/watch/XXXXXX" style="position:absolute; left:-9999px;" alt=""></noscript>-->
@mihdan
mihdan / wp-schema-pro-filter-blog-posting.php
Created July 10, 2023 09:53
Расширяет микроразметку BlogPosting в плагине WP Schema Pro для получения контентной аналитики (дочитываемость, категории, автора, тематики) в Яндекс.Метрике
<?php
add_filter(
'wp_schema_pro_schema_article',
/**
* Расширяет микроразметку BlogPosting для Яндекс.Метрики.
*
* @link https://metrika.yandex.ru/support/metrica/publishers/schema-org/json-ld.html#json-ld__identifier-desc
*
* @param array $schema Схема.
* @param array $data Данные.
@ian-svoboda-prom
ian-svoboda-prom / async-enqueues.php
Last active January 25, 2025 01:13
Apply async/non-blocking loading to link tags in WordPress
<?php
/**
* Inpspired by Scott Jehl: https://www.filamentgroup.com/lab/load-css-simpler/
*
**/
add_action( 'style_loader_tag', 'async_preload_stylesheets', 99, 4 );
function async_preload_stylesheets( string $tag, string $handle, string $href, string $media ) : string {
// Add the stylesheet handles you want to load async
$allowlist = [ 'your-stylesheet-handle' ];
@josethz00
josethz00 / sr-frontend-interview-questions-answered.md
Last active April 25, 2025 07:21
Sr. Frontend Interview Questions

Senior Frontend Interview Questions

Some questions about frontend development that might be in your next job interview. The questions were formulated by @mauvieira, a super senior fullstack developer

General Frontend

  • What are the strategies we can use to optimize the performance of web applications?

    • CDNs, GraphQL (maybe) to reduce overfetching, improve backend performance, use SSR and/or SSG, lazy loading for loading assets only when it's needed, minimize and compress HTML, CSS and JS files, and optimize images by compressing and resizing them.
  • What are Web Vitals (LCP, FID, CLS)? And how are they applied in the real world?

<?php
/**
* Optimize Loading Separate Core Block Assets in Classic Themes Plugin.
*
* @package OptimizeLoadingSeparateCoreBlockAssetsInClassicThemes
* @author Weston Ruter
* @link https://gist.github.com/westonruter/25187db63a7666f08b151ca53497ffb5
* @license GPL-2.0-or-later
* @copyright 2023 Google Inc.
*
@lupetalo
lupetalo / elementor_activator.php
Last active May 9, 2025 12:19
Elementor Activator
<?php
/**
* Plugin Name: Elementor Activation
* Description: Activates Elementor Pro - Not everybody have shell acces to run WP CLI or desire for eveybody to see license key. Manual activation is needed, and since Elementor wont add this, community will :)
* Plugin URI: https://github.com/elementor/elementor/issues/8667
* Gist Plugin URI: https://gist.github.com/lupetalo/38e6d40b620b7da976c42c2d207c674a
* Version: 1.3
*/
add_filter('pre_http_request', function($request, $request_params, $url){
if (strpos($url, 'my.elementor.com/api/v2/license/')!==false){