We usually get a requirement that Visualforce page needs to
be loaded either from lightning or from Javascript or from any other
Visualforce page in an iframe.
We had the same requirement too! Loading Visualforce page
from lightning, but major road blocker was performance, Visualforce page was
taking almost 3 seconds to load in an iframe.
When we use Visualforce page, we use relative URL like
/apex/PageName, when we call Visualforce page from another Visualforce page, we
don’t face performance issue, because it will be in same origin and server i.e.
visualforce.com.
But when we call the same form lightning, both the server and
origin are different, further if you call page in an iframe, it is even slower.
To avoid loading and performance issue, use absolute URL i.e.
https://domain+Namespace.visualforce.com/apex/PageName
You can create absolute URL from below code:-
vfUrl = 'https://'+URL.getSalesforceBaseURL().getHost()+
‘/apex/PageName’
Or
If your org has domain name and namespace [Suppose my org
namespace is Test]:-