WPIntell

Source evidence

Idea to make this plugin even better and more performant

ConvertCalculator: Build Cost, Price, Quotation, ROI Interactive Calculators · support · 2021-07-10T19:50:00+00:00

complaintsentiment
mediumseverity
0.75relevance
0replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

7 / 33 rows with source links

21.2% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

26 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Ryan Kienstra unresolved
This is a great plugin. Especially because the calculator is interactive. One thing that might make the plugin even better is improving its performance when there’s no ConvertCalculator shortcode. With this change, this plugin’s JavaScript will only load on pages that have a ConvertCalculator shortcode: diff --git a/convertcalculator.php b/convertcalculator.php index 9c76e99..68e5215 100644 --- a/convertcalculator.php +++ b/convertcalculator.php @@ -10,23 +10,17 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly - function convertcalculator_hook_javascript() { - wp_enqueue_script("convertcalculator-script", "https://app.convertcalculator.co/embed.js", array(), false, false); - } - - add_action( 'wp_enqueue_scripts', 'convertcalculator_hook_javascript' ); - function convertcalculator_script_loader_tag($tag, $handle) { if ($handle === 'convertcalculator-script') { if (false === stripos($tag, 'async')) { $tag = str_replace(' src', ' async="async" src', $tag); } if (false === stripos($tag, 'defer')) { $tag = str_replace('<script ', '<script defer ', $tag); } } return $tag; } @@ -41,8 +35,9 @@ add_filter('script_loader_tag', 'convertcalculator_script_loader_tag', 10, 2); return '<div>You need to add an "id" to the "convertcalculator" shortcode. You can find the calculator id in the <a href="https://app.convertcalculator.co">editor</a>.'; } + wp_enqueue_script("convertcalculator-script", "https://app.convertcalculator.co/embed.js", array(), false, true); return '<div class="calculator" data-calc-id="' . $atts['id'] .'"></div>'; } add_shortcode( 'convertcalculator', 'convertcalculator_embed_calculator' ); Right now, the JavaScript file loads on every URL, even if there’s no ConvertCalculator: https://cldup.com/N_BCI6ZJ0Z.png This is a great plugin, thanks for your work. This topic was modified 4 years, 10 months ago by Ryan Kienstra . This topic was modified 4 years, 10 months ago by Ryan Kienstra .

Comments

0 shown

No comments were stored for this source.