Flux is either of two separate simple and ubiquitous concepts throughout physics and applied mathematics. Within a discipline, the term is generally used consistently, but care must be taken when comparing phenomena from different disciplines. Both concepts have mathematical rigor, enabling comparison of the underlying math when the terminology is unclear. For transport phenomena, flux is a vector quantity, describing the magnitude and direction of the flow of a substance or property. In electromagnetism, flux is a scalar quantity, defined as the surface integral of the component of a vector field perpendicular to the surface at each point. As will be made clear, the easiest way to relate the two concepts is that the surface integral of a flux according to the first definition is a flux according to the second definition.
The word flux comes from Latin: fluxus means "flow", and fluere is "to flow". As fluxion, this term was introduced into differential calculus by Isaac Newton.
One could argue, based on the work of James Clerk Maxwell, that the transport definition precedes the way the term is used in electromagnetism. The specific quote from Maxwell is:
In the case of fluxes, we have to take the integral, over a surface, of the flux through every element of the surface. The result of this operation is called the surface integral of the flux. It represents the quantity which passes through the surface.
According to the first definition, flux may be a single vector, or flux may be a vector field / function of position. In the latter case flux can readily be integrated over a surface. By contrast, according to the second definition, flux is the integral over a surface; it makes no sense to integrate a second-definition flux for one would be integrating over a surface twice. Thus, Maxwell's quote only makes sense if "flux" is being used according to the first definition (and furthermore is a vector field rather than single vector). This is ironic because Maxwell was one of the major developers of what we now call "electric flux" and "magnetic flux" according to the second definition. Their names in accordance with the quote (and first definition) would be "surface integral of electric flux" and "surface integral of magnetic flux", in which case "electric flux" would instead be defined as "electric field" and "magnetic flux" defined as "magnetic field". This implies that Maxwell conceived as these fields as flows/fluxes of some sort.