Uncategorized

Ruby find inside a hash or array

@selected_rate=@rates(“rates is a array object”).select {|rates| rates[“object_id”] == @shippo_order.rate_id } new thing is every variable or object instance we make in ruby have there won object_id,that can be aaccess by @instance or variable .object_id we can get the selected rates like :-<%=@selected_rate[0][“object_id”]%> my @rates object

How to set defer or async attributes on enqueued script tags in WordPress

  <?php add_action( ‘wp_enqueue_scripts’, function () { wp_register_script( ‘my-script’, get_stylesheet_directory_uri() . ‘/assets/js/my-script.js’ ); wp_enqueue_script( ‘my-script’ ); } ); add_filter( ‘script_loader_tag’, function ( $tag, $handle ) { if ( ‘my-script’ !== $handle ) { return $tag; } return str_replace( ‘ src’, ‘ defer src’, $tag ); // defer the script //return str_replace( ‘ src’, ‘ async …

How to set defer or async attributes on enqueued script tags in WordPress Read More »