I'm trying to add a simple js that has to be executed on documentReady with jQuery.
Script js
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'domReady!',
], function ($) {
//Script code
});
Also, it needs to be on a module, not a theme, on every page, adminhtml and frontend. I've tried adding the script with a default.xml like this
<?xml version="1.0"?>
<page xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<head>
<link src="Custom_Iframe::js/iframe.js"/>
</head>
</page>
However, this puts the script before every other script, including require-js and jQuery.
I know i can make it a module and then a block that loads the module, but i cannot understand how to do that, and i've been on the second page of google checking for answers on multiple searches.
I've also tried this answer https://magento.stackexchange.com/a/131635, but then, the script never gets loaded.