• Hi Frank,

    how are you?

    We are including all the “inline js code” in our autoptimized js file.

    In our scripts, we have:

    wp_localize_script($this->places_gmaps, ‘places_gmaps’, $places_gmaps_settings);

    It includes dinamyc params, I mean the lat/lng coordinates, for multiple pages… so we would like to EXCLUDE just this inline snippet and we need to “echo” it AFTER your autoptimize JS file. Is it possible?

    Hope I was clear, I am sorry.

    @futtta

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frank Goossens

    (@futtta)

    I’m fine, thanks you @daweb ??

    assuming the localized JS has places_gmaps in the inlined JS, you could use that string to exclude?

    Thread Starter Davide Prevosto

    (@daweb)

    May you remember me how to exclude it using places_gmaps?

    Plugin Author Frank Goossens

    (@futtta)

    Sure; add that string to the comma-separated “Exclude scripts from Autoptimize”-field.

    Thread Starter Davide Prevosto

    (@daweb)

    Thank you Frank. And how to append this snippet AFTER the minification?
    Is it possible? I need jQuery, and it is minified into the autoptimize js. I wouldn’t remove it from minification.

    Plugin Author Frank Goossens

    (@futtta)

    well, you can instruct AO to inject the JS elsewhere using the API (see autoptimize_helper.php_example for an example of how to use the autoptimize_filter_js_replacetag filter), so you can change that.

    but normally wp_localize_script just outputs the JS object and that object is used by a normally enqueued script which can be optimized, in which case you would not need to juggle with the JS injection point to begin with?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP Localize Script’ is closed to new replies.