You would use the $(window).on('load')
event instead of the $(document).ready()
like you attempted.
This would wait for all elements on the page to load before triggering.
$(window).on('load', function() {
// Perform tasks after everything has loaded.
});